const express = require('express');
const path = require('path');
const bodyPaser = require('body-parser');
const session = require('express-session');
const app = express();

require('./model/connect.js');

app.use(bodyPaser.urlencoded({ extended: false }))

app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'art');
app.engine('art', require('express-art-template'));

app.use(express.static(path.join(__dirname, 'public')));

app.use(session({ secret: 'secret key' }));

const home = require('./route/home');
const admin = require('./route/admin');

app.use('/admin', require('./middleware/loginGuard'));

app.use('/home', home);
app.use('/admin', admin);

app.listen(80);
console.log('网站服务器启动成功，请访问localhost');